package edu.purdue.cs.aggr.message;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;

import edu.purdue.cs.aggr.AccumulatorFactory.AccumulatorType;

public class VertexSetupMessage extends Message {

	private List<String> sourceVertices = new ArrayList<String>();
	private String destinationVertex = null;
	private boolean inputReader = false;
	private String inputFile = null;
	private String hdfsNamenode = null;
	private AccumulatorType accumulatorType;
	private Integer accumulatorSubtype;

	public VertexSetupMessage() {
	}

	@Override
	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		super.readExternal(in);
		sourceVertices = (List<String>) in.readObject();
		destinationVertex = (String) in.readObject();
		inputReader = in.readBoolean();
		inputFile = (String) in.readObject();
		hdfsNamenode = (String) in.readObject();
		accumulatorType = (AccumulatorType) in.readObject();
		accumulatorSubtype = (Integer) in.readObject();
	}

	@Override
	public void writeExternal(ObjectOutput out) throws IOException {
		super.writeExternal(out);
		out.writeObject(sourceVertices);
		out.writeObject(destinationVertex);
		out.writeBoolean(inputReader);
		out.writeObject(inputFile);
		out.writeObject(hdfsNamenode);
		out.writeObject(accumulatorType);
		out.writeObject(accumulatorSubtype);
	}

	public List<String> getSourceVertices() {
		return sourceVertices;
	}

	public void setSourceVertices(List<String> sourceVertices) {
		this.sourceVertices = sourceVertices;
	}
	
	public String getDestinationVertex() {
		return destinationVertex;
	}
	
	public void addSourceVertex (String sourceVertex) {
		sourceVertices.add(sourceVertex);
	}

	public void setDestinationVertex(String destinationVertex) {
		this.destinationVertex = destinationVertex;
	}

	public boolean isInputReader() {
		return inputReader;
	}

	public void setInputReader(boolean inputReader) {
		this.inputReader = inputReader;
	}

	public String getInputFile() {
		return inputFile;
	}

	public void setInputFile(String inputFile) {
		this.inputFile = inputFile;
	}

	public String getHdfsNamenode() {
		return hdfsNamenode;
	}

	public void setHdfsNamenode(String hdfsNamenode) {
		this.hdfsNamenode = hdfsNamenode;
	}

	public AccumulatorType getAccumulatorType() {
		return accumulatorType;
	}

	public void setAccumulatorType(AccumulatorType accumulatorType) {
		this.accumulatorType = accumulatorType;
	}

	public Integer getAccumulatorSubtype() {
		return accumulatorSubtype;
	}

	public void setAccumulatorSubtype(Integer accumulatorsubType) {
		this.accumulatorSubtype = accumulatorsubType;
	}
}
